package com.cloudjan.codebuilder.util;

import com.google.common.base.CaseFormat;
import org.apache.commons.io.IOUtils;

import java.io.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

/**
 * 压缩工具类
 */
public class ZipUtil {

    public void generatZip(ZipOutputStream zip,String packageName,String moduleName,String TableName,String type){
        String packagePath = "main" + File.separator + "java" + File.separator+packageName.replace(".", File.separator) + File.separator;
        packagePath += type + File.separator + moduleName + CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, type) + ".java";
        try {
            //添加到zip
            zip.putNextEntry(new ZipEntry(packagePath));
//            IOUtils.write(sw.toString(), zip, "UTF-8");
//            IOUtils.closeQuietly(sw);
//            zip.closeEntry();
        } catch (IOException e) {
            throw new RuntimeException("渲染模板失败，表名：" + TableName, e);
        }
    }

}
